package com.example.administrator.kaohedemo.Utils;

import android.content.Context;
import android.view.WindowManager;

/**
 * Created by Administrator on 2016/6/22.
 */
public class Utils {

    /**
     * 得到屏幕宽度
     */
    public static int getScreenWidth(Context context) {
        return ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay().getWidth();
    }

    public static String getTimeFromSum(String sum){
        int number=0;
        try {
            number=Integer.parseInt(sum);
        }catch (Exception e){
            throw new IllegalArgumentException("sum must be number");
        }
        String time="";
        int seconds=number%60;
        int minutes=number/60;

        int minutes2=minutes%60;
        int hours=minutes/60;

        time=getStandTimeFromSum(hours)+":"+getStandTimeFromSum(minutes2)+":"+getStandTimeFromSum(seconds);
        return time;
    }

    private static String getStandTimeFromSum(int sum){
        String time="";
        if (sum<10){
            time="0"+sum;
        }else {
            time=""+sum;
        }
        return time;
    }
}
